import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Employee {
    private String name;
    private int age;
    private String gender;
    private String position;
    private double salary;
    private String employeeId;

    public Employee(String name, int age, String gender, String position, double salary, String employeeId) {
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.position = position;
        this.salary = salary;
        this.employeeId = employeeId;
    }

    @Override
    public String toString() {
        return "工号: " + employeeId + ", 姓名: " + name + ", 年龄: " + age + ", 性别: " + gender +
                ", 职务: " + position + ", 薪水: " + salary;
    }
}

class Company {
    private String companyName;
    private String registeredAddress;
    private String phone;
    private String businessScope;
    private List<Employee> employees;

    public Company(String companyName, String registeredAddress, String phone, String businessScope) {
        this.companyName = companyName;
        this.registeredAddress = registeredAddress;
        this.phone = phone;
        this.businessScope = businessScope;
        this.employees = new ArrayList<>();
    }

    public void hireEmployee(Employee employee) {
        for (Employee emp : employees) {
            if (emp.getEmployeeId().equals(employee.getEmployeeId())) {
                System.out.println("错误：工号已存在。");
                return;
            }
        }
        employees.add(employee);
        System.out.println("员工招聘成功：" + employee);
    }

    public void fireEmployee(String employeeId) {
        Employee toFire = null;
        for (Employee emp : employees) {
            if (emp.getEmployeeId().equals(employeeId)) {
                toFire = emp;
                break;
            }
        }
        if (toFire != null) {
            employees.remove(toFire);
            System.out.println("员工辞退成功：" + toFire);
        } else {
            System.out.println("未找到工号为 " + employeeId + " 的员工。");
        }
    }

    public void printEmployeeInfo() {
        for (Employee emp : employees) {
            System.out.println(emp);
        }
    }

    public int getEmployeeCount() {
        return employees.size();
    }

    public Employee getHighestPaidEmployee() {
        Employee highestPaid = null;
        for (Employee emp : employees) {
            if (highestPaid == null || emp.getSalary() > highestPaid.getSalary()) {
                highestPaid = emp;
            }
        }
        return highestPaid;
    }
}

public class Main {
    public static void main(String[] args) {
        Company company = new Company("xx集团", "xx路666号", "123456789", "xx研发");
        Scanner scanner = new Scanner(System.in);
        int choice = 0;
        boolean exit = false;

        while (!exit) {
            System.out.println("请选择一个操作：");
            System.out.println("1: 招聘新员工");
            System.out.println("2: 辞退员工");
            System.out.println("3: 打印员工信息");
            System.out.println("4: 获取公司员工总数");
            System.out.println("5: 获取薪水最高的员工");
            System.out.println("0: 退出");

            try {
                choice = Integer.parseInt(scanner.nextLine());

                switch (choice) {
                    case 1:
                        System.out.println("请输入员工详细信息（工号, 姓名, 年龄, 性别, 职务, 薪水）：");
                        String[] details = scanner.nextLine().split(", ");
                        Employee newEmployee = new Employee(details[1], Integer.parseInt(details[2]), details[3], details[4], Double.parseDouble(details[5]), details[0]);
                        company.hireEmployee(newEmployee);
                        break;
                    case 2:
                        System.out.println("请输入要辞退员工的工号：");
                        String employeeId = scanner.nextLine();
                        company.fireEmployee(employeeId);
                        break;
                    case 3:
                        company.printEmployeeInfo();
                        break;
                    case 4:
                        System.out.println("公司员工总数为：" + company.getEmployeeCount());
                        break;
                    case 5:
                        Employee highestPaid = company.getHighestPaidEmployee();
                        if (highestPaid != null) {
                            System.out.println("薪水最高的员工信息：" + highestPaid);
                        } else {
                            System.out.println("目前没有员工记录。");
                        }
                        break;
                    case 0:
                        exit = true;
                        break;
                    default:
                        System.out.println("输入的选项不存在，请重新输入。");
                }
            } catch (NumberFormatException e) {
                System.out.println("输入错误，请输入一个有效的数字。");
            }
        }

        scanner.close();
    }
}

